package likou.tanxin;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2020/11/15 18:52
 */
//不含 AAA 或 BBB 的字符串
public class _984 {
    class Solution {
        public String strWithout3a3b(int A, int B) {
            char[] chars = new char[A+B];
            int index = 0;
            int p = 0;
            while(A>B){
                chars[index] = 'a';
                index++;
                A--;
                p++;
                if(p==2&&B!=0){
                    p=0;
                    chars[index] = 'b';
                    index++;
                    B--;
                }
            }
            p = 0;
            while(A<B){
                chars[index] = 'b';
                index++;
                B--;
                p++;
                if(p==2&&A!=0){
                    p=0;
                    chars[index] = 'a';
                    index++;
                    A--;
                }
            }
            while(A!=0||B!=0){
                if(A!=0){
                    chars[index] = 'a';
                    A--;
                    index++;
                }
                if(B!=0){
                    chars[index] = 'b';
                    B--;
                    index++;
                }
            }
            return new String(chars);
        }
    }
}
